#include "../Queue/Deque.hpp"
#include "../LinkList.hpp"
#include "../Queue/LinkQueue.hpp"
#include "../Queue/RearQueue.hpp"
#include "../Queue/TagQueue.hpp"

#include <iostream>

using namespace std;

void hw4_1()
{
    RearQueue rq;

    cout << "队列是否为空?" << (rq.rearQueueEmpty() ? "是" : "否") << endl;

    rq.enRearQueue(10);
    rq.enRearQueue(20);
    rq.enRearQueue(30);

    cout << "队列是否为空?" << (rq.rearQueueEmpty() ? "是" : "否") << endl;

    QElemType e;
    rq.deRearQueue(e);
    cout << "出队元素: " << e << endl;

    cout << "队列是否为空?" << (rq.rearQueueEmpty() ? "是" : "否") << endl;

    rq.clearRearQueue();

    cout << "队列是否为空?" << (rq.rearQueueEmpty() ? "是" : "否") << endl;
}

void hw4_2()
{
    TagQueue tq;

    cout << "入队元素: ";
    for (int i = 0; i < 100; i++) {
        if (tq.enTagQueue(i) == tq.Status::Ok) {
            cout << i << " ";
        }
    }
    cout << endl;

    if (!tq.enTagQueue(101)) {
        cout << "队列已满，入队操作失败!" << endl;
    }

    cout << "出队元素: ";
    QElemType e;
    while (!tq.isEmpty()) {
        if (tq.deTagQueue(e) == tq.Status::Ok) {
            cout << e << " ";
        }
    }
    cout << endl;

    if (tq.deTagQueue(e) == tq.Status::Err)
        cout << "队列为空，出队操作失败" << endl;
}

void hw4_3()
{
    Deque dq;
    dq.enRear(10);
    dq.enRear(20);

    dq.enFront(5);

    QElemType e;
    dq.deRear(e);
    cout << "队列尾部出列元素为: " << e << endl;

    dq.deFront(e);
    cout << "队列头部出列元素为: " << e << endl;
}

void hw4_4()
{
    LinkList ll(3);
    ll.addNode(5);
    ll.addNode(2);
    ll.addNode(8);

    cout << "最大值: " << ll.Max() << endl;
    cout << "元素数量: " << ll.Count() << endl;
    cout << "平均值: " << ll.Average() << endl;
}

int main()
{

    hw4_4();

    return 0;
}
